import axios, { AxiosResponse } from "axios";

class NetApis {
    getIp(): Promise<string> {
        const promise: Promise<string> = new Promise<string>((resolve, reject) => {
            axios.get('https://ip.useragentinfo.com/json?ip=')
                .then((reslut: AxiosResponse) => {
                    const ip: string = reslut.data.ip;
                    resolve(ip);
                })
                .catch((error) => {
                    reject(error);
                })
        });
        return promise;
    }

    getProvince(): Promise<string> {
        const promise: Promise<string> = new Promise<string>((resolve, reject) => {
            axios.get('https://ip.useragentinfo.com/json?ip=')
                .then((reslut: AxiosResponse) => {
                    const province: string = reslut.data.province;
                    resolve(province);
                })
                .catch((error) => {
                    reject(error);
                })
        });
        return promise;
    }
}

export const netApis: NetApis = new NetApis();